package com.huirui.server.pojo.dto;

import lombok.Data;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;

/**
 * 订单设置DTO
 *
 * @author huirui
 */
@Data
public class OrderSettingDto {

    /**
     * 设置ID（主键，新增时为null，更新时必填）
     */
    @Null(message = "新增时ID必须为空", groups = AddGroup.class)
    @NotNull(message = "更新时ID不能为空", groups = UpdateGroup.class)
    private Long id;

    /**
     * 秒杀订单超时时间（单位：分钟，超时未支付自动取消）
     */
    @NotNull(message = "秒杀订单超时时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 5, message = "秒杀订单超时时间不能小于5分钟", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 120, message = "秒杀订单超时时间不能大于120分钟", groups = {AddGroup.class, UpdateGroup.class})
    private Integer flashOrderOvertime;

    /**
     * 普通订单超时时间（单位：分钟，超时未支付自动取消）
     */
    @NotNull(message = "普通订单超时时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 10, message = "普通订单超时时间不能小于10分钟", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 240, message = "普通订单超时时间不能大于240分钟", groups = {AddGroup.class, UpdateGroup.class})
    private Integer normalOrderOvertime;

    /**
     * 自动确认收货超时时间（单位：小时，发货后超过此时长自动确认收货）
     */
    @NotNull(message = "自动确认收货时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 24, message = "自动确认收货时间不能小于24小时", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 168, message = "自动确认收货时间不能大于168小时", groups = {AddGroup.class, UpdateGroup.class})
    private Integer confirmOvertime;

    /**
     * 订单完成后自动结束超时时间（单位：天，确认收货后超过此时长自动结束订单）
     */
    @NotNull(message = "订单自动结束时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 7, message = "订单自动结束时间不能小于7天", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 30, message = "订单自动结束时间不能大于30天", groups = {AddGroup.class, UpdateGroup.class})
    private Integer finishOvertime;

    /**
     * 自动评价超时时间（单位：天，订单完成后超过此时长自动好评）
     */
    @NotNull(message = "自动评价时间不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @Min(value = 7, message = "自动评价时间不能小于7天", groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 30, message = "自动评价时间不能大于30天", groups = {AddGroup.class, UpdateGroup.class})
    private Integer commentOvertime;

    /**
     * 免运费门槛金额
     */
    @NotNull(message = "免运费门槛金额不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @DecimalMin(value = "0", inclusive = true, message = "免运费门槛金额不能小于0", groups = {AddGroup.class, UpdateGroup.class})
    private BigDecimal freeShippingThreshold;

    /**
     * 运费金额
     */
    @NotNull(message = "运费金额不能为空", groups = {AddGroup.class, UpdateGroup.class})
    @DecimalMin(value = "0", inclusive = true, message = "运费金额不能小于0", groups = {AddGroup.class, UpdateGroup.class})
    private BigDecimal shippingPrice;

    /**
     * 新增分组
     */
    public interface AddGroup {}

    /**
     * 更新分组
     */
    public interface UpdateGroup {}
}